package com.go.ssm.web.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import com.go.ssm.domain.common.PageModel;
import com.go.ssm.util.Constants;
import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;
	protected PageModel pageModel = new PageModel();
	
	public PageModel getPageModel() {
		return pageModel;
	}

	public void setPageModel(PageModel pageModel) {
		this.pageModel = pageModel;
	}

	public String urlEncode(String name) throws UnsupportedEncodingException{
		return urlEncode(name, "utf-8");
	}
    
    public String urlEncode(String name,String charset) throws UnsupportedEncodingException {
		return URLEncoder.encode(name, charset);
	}
    
    public String urlDecode(String name) throws UnsupportedEncodingException {
    	return urlDecode(name, "utf-8");
    }
    
    public String urlDecode(String name,String charset) throws UnsupportedEncodingException {
		return URLDecoder.decode(name, charset);
    }
    
	public String getStaticFilePrefix() {
		return Constants.STATIC_FILE_URL_PREFIX;
	}    
}
